//
//  LSZParentClassNotificationDetailsVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/28.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZParentClassNotificationDetailsVC.h"

@interface LSZParentClassNotificationDetailsVC ()<LCDisplayViewControllerDelegate>

//@property (strong, nonatomic) LCTopTitleImageBar *topTitleImageBar;
@property (strong, nonatomic) UIView *viewFenGe;

@end

@implementation LSZParentClassNotificationDetailsVC

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //    _topTitleImageBar.isPushSerach = YES;
}
- (void)viewDidLoad {
    self.title = self.stringTitle;
    self.delegate = self;
    [self setupAllViewController];
    [self setupAllVCData];
    self.view.backgroundColor = [UIColor whiteColor];
    UIView * viewFenGe = [[UIView alloc]initWithFrame:CGRectMake(0, 43+NAVIGATION_BAR_HEIGHT, ScreenWidth, 1)];
    _viewFenGe = viewFenGe;
    viewFenGe.backgroundColor = divider;
    [self.view addSubview:viewFenGe];
    [viewFenGe sendSubviewToBack:self.view];
    /**增加侧滑返回,无其他作用*/
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, ScreenHeight)];
    [self.view addSubview:view];
    [self.view bringSubviewToFront:view];
    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"全部阅读" style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOKbtn)];
    self.navigationItem.rightBarButtonItem = rightBarItem;
}
- (void)setupAllViewController {
    // 标题渐变
    // *推荐方式(设置标题渐变)
    [self setUpTitleGradient:^(LCTitleColorGradientStyle *titleColorGradientStyle, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor) {
        *norColor = RGBColor(140, 140, 140);
        // 设置标题选中颜色
        *selColor = RGBColor(238, 82, 74);
    }];
    // 设置标题字体
    // 推荐方式
    [self setUpTitleEffect:^(UIColor *__autoreleasing *titleScrollViewColor, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor, UIFont *__autoreleasing *titleFont, CGFloat *titleHeight, CGFloat *titleWidth) {
        // 设置标题字体
        if (ScreenWidth == 414) {
            *titleFont = FONT_(15.5);
        }else
            if (ScreenWidth == 375) {
                *titleFont = FONT_15;
            }else{
                *titleFont = FONT_(14.5);
            }
    }];
}
- (void)setupAllVCData {
    // 移除之前所有子控制器
    [self.childViewControllers makeObjectsPerformSelector:@selector(removeFromParentViewController)];
    NSArray *titleDatas = [[NSArray alloc]init];
    titleDatas = @[@"点赞",@"评论"];
    for (NSInteger i = 0; i < titleDatas.count; i++) {
        if (i == 0) {
            LSZClassificationDetailsVC * vc = [[LSZClassificationDetailsVC alloc]init];
            vc.title = titleDatas[i];
            vc.type =self.type;
            vc.tag = @"1,2,3";
            vc.kind = self.kind;
            [self addChildViewController:vc];
        }
        else if ([titleDatas[i] isEqualToString:@"评论"]) {
            LSZClassificationDetailsVC * vc = [[LSZClassificationDetailsVC alloc]init];
            vc.title = titleDatas[i];
            vc.type = self.type;
            vc.tag = @"4,5";
            vc.kind = self.kind;
            [self addChildViewController:vc];
        }
        else{
        }
    }
    // 注意：必须先确定子控制器
    [self refreshDisplay];
}
-(void)tabBarContentViewDidSelectItemAtIndex:(NSInteger)index{
    NSLog(@"tabBarContentViewDidSelectItemAtIndex = %zd", index);
}
//标签头部底部分割线
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    [_viewFenGe sendSubviewToBack:self.view];
}
-(void)onClickedOKbtn
{
    if([[_UserM msg_not_read] integerValue] == 0){
        [self setStringWarning:@"全部已读!"];
    }else{
        [LSZRequestData readTheInformationInTheNotice:@"2" strID:@"" :^(BOOL isOK, NSString * string, NSDictionary * diction) {
            if (isOK == YES) {
                [_UserM setMsg_not_read:@"0"];
                [self setStringWarning:@"已设置全部已读!"];
                NSNotification *notification =[NSNotification notificationWithName:@"allHaveBeenRead" object:nil userInfo:nil];
                [[NSNotificationCenter defaultCenter] postNotification:notification];
                [[NSNotificationCenter defaultCenter] removeObserver:self name:@"allHaveBeenRead" object:nil];
            }else{
                [self setStringWarning:string];
            }
        }];
    }
}
-(void)setStringWarning:(NSString *)string
{
    AlertKuangView * alert = [AlertKuangView new];
    [alert moveJingGaoKuang:string:self.view];
}
@end
